package com.presto.directo.mvvm.view

import android.content.Intent
import android.os.Bundle
import android.view.View
import com.google.android.gms.ads.identifier.AdvertisingIdClient
import com.presto.directo.base.BaseActivity
import com.presto.directo.mvvm.viewmodel.emptyStatus
import com.presto.directo.mvvm.viewmodel.loanStatus
import com.presto.directo.utils.*
import kotlinx.coroutines.*

class SplashActivity : BaseActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        loanStatus = emptyStatus()
        start(onNext = {
            delay(1000)
            val intent = Intent(this, MainActivity::class.java)
            startActivity(intent)
            finish()
        })
        start(onNext = {
            withContext(Dispatchers.IO) {
                val gaId = AdvertisingIdClient.getAdvertisingIdInfo(applicationContext).id ?: ""
                SPUtil.put("gaId", gaId)
            }
        }, toast = false)
    }

    override val rootView: View?
        get() = null

}